package com.cetccloud.ap.util;

import org.springframework.http.server.reactive.ServerHttpRequest;
import reactor.core.publisher.Mono;

/**
 * @ClassName ReactiveRequestContextHolder
 * @Description TODO
 * @Author superz
 * @Date 2021/4/20 17:59
 * @Version 1.0
 **/
public class ReactiveRequestContextHolder {

    public static final Class<ServerHttpRequest> CONTEXT_KEY = ServerHttpRequest.class;

    public static Mono<ServerHttpRequest> getRequest() {
        return Mono.subscriberContext().map(ctx -> ctx.get(CONTEXT_KEY));
    }

}
